# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from rest_framework import mixins
from rest_framework import viewsets

from .serialzer import AuthorSerializer, AuthorContactSerializer

from django_filters import rest_framework

from .models import Author, AuthorContact

# Create your views here.


class AuthorViewSet(viewsets.GenericViewSet,
                    mixins.ListModelMixin,
                    mixins.RetrieveModelMixin):
    queryset = Author.objects.all()
    serializer_class = AuthorSerializer


class AuthorContactViewSet(viewsets.GenericViewSet,
                           mixins.ListModelMixin):
    queryset = AuthorContact.objects.filter(is_use=0)
    serializer_class = AuthorContactSerializer
    filter_backends = (rest_framework.DjangoFilterBackend,)
    filter_fields = ('author_id',)
